﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using DAL;
public partial class UpLoadImages_Upload : System.Web.UI.Page
{
    DAL.DataClassesDataContext lqDB = new DataClassesDataContext(System.Configuration.ConfigurationManager.ConnectionStrings["CMSConnectionString"].ToString());
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                if (!CMSUser.Current.IsLogin)
                {
                    Response.Redirect("~/Login.aspx");
                }
            }
            catch (Exception)
            {
                Response.Redirect("~/Login.aspx");
            }
        }
    }
    //上传图片
    protected void btnOk_Click(object sender, EventArgs e)
    {
        if (this.txtFilePath.Text != "")
        {
            //取得文件路径
            string FilePath = this.txtFilePath.Text;
            string Des = this.txtDes.Text;
            //将图片路径存入数据库中
            string id = Request.QueryString["id"].ToString();
            try
            {
                DAL.ProjectImages img = new DAL.ProjectImages();
                img.Project_ID = id;
                img.Images_Path = FilePath;
                img.Img_Des = Des;
                lqDB.ProjectImages.InsertOnSubmit(img);
                lqDB.SubmitChanges();
                Response.Write("<script language=javascript>alert('上传成功！')</script>");
            }
            catch (Exception ex)
            {
                throw ex;
            }
            this.txtFilePath.Text = "";
            //Frame.Global.GlobalFunctions.AlertToUrl("上传成功！","");

        }

    }
}